package com.vcms.entity.store;

import com.vcms.entity.store.item.CashStoreItem;
import com.vcms.entity.store.item.StoreItem;
import com.vcms.entity.store.itemtype.Coin;

// Copyright 1997 ISS.
// The contents contained in this document may not be reproduced in any
// form or by any means, without the written permission of ISS, other
// than for the purpose for which it has been supplied.
//
// Author: Olivo Miotto
//
//

public class CashStore extends Store {

	public final static int INVALID_COIN_WEIGHT = 9999;

	public CashStore() {}
	
	public Coin findCoin(double weight){
		for(StoreItem storeItem : super.getItems()){
			Coin coin = (Coin) storeItem.getContent();
			if(coin.getWeight() == weight)
				return coin;
		}
		return null;
	}
	
	public int findCashStoreIndex (Coin coin) {
		int size = getStoreSize();
		try{
			for (int i = 0; i < size; i++) {
				StoreItem item = (CashStoreItem) super.getStoreItem(i);
				Coin current = (Coin) item.getContent();
				if (current.getWeight() == coin.getWeight())
					return i;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return -1;
	}

}
